﻿using AutoDeployForSims.Entity;
using AutoDeployForSims.Service;
using AutoDeployForSims.Utility;
using MyUtility.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoDeployForSims.Model
{
    public class AppInfoModel
    {
        private GetConfigService getConfigService = SingletonProvider<GetConfigService>.Instance;

        private List<AppStatusEntity> appStatusEnts = new List<AppStatusEntity>();
        private List<AppStatusEntity> newAppStatusEnts = new List<AppStatusEntity>();
        private List<AppStatusEntity> appStatusEntities = new List<AppStatusEntity>();
        public List<AppStatusEntity> AppStatusEntities
        { get{ return appStatusEntities; } 
          set { appStatusEntities = value; } }

        public AppInfoModel()
        {
            InitApp();
        }

        public bool AddApp(AppStatusEntity appStatusEntity)
        {
            bool isRight = false;
            appStatusEntities.Add(appStatusEntity);

            isRight = true;
            return isRight;
        }


        public bool InitApp()
        {
            bool isRight = false;

            appStatusEntities.Clear();

            if (getConfigService.ReadAPPStartPathConfig(ref appStatusEnts))
            {
                if (appStatusEntities != null)
                {
                    appStatusEntities = appStatusEnts;
                }
            }
            if (getConfigService.ReadNewAPPStartPathConfig(ref newAppStatusEnts))
            {
                if (appStatusEntities != null)
                {
                    foreach (var item in newAppStatusEnts)
                    {
                        appStatusEntities.Add(item);
                    }
                    
                }
            }

            return isRight;
        }


        public bool DeleteApp(AppStatusEntity appStatusEntity)
        {
            bool isRight = false;

            appStatusEntities.Remove(appStatusEntity);

            isRight = true;
            return isRight;
        }

    }
}
